package com.ticket.common.utils;

/**
 * 号码（加密）替换工具类型
 */
public class NumberReplaceUtils {

    /**
     * 身份证号加*
     * @param idCard 身份证号
     * @return
     */
    public static String idCardAddStar(String idCard) {
        String res = "";
        if (!StringUtils.isEmpty(idCard)) {
            StringBuilder stringBuilder = new StringBuilder(idCard);
            res = stringBuilder.replace(6, 14, "********").toString();
        }
        return res;
    }

    /**
     * 护照证号加*
     * @param idCard 护照证号
     * @return
     */
    public static String passportAddStar(String idCard) {
        String res = "";
        if (!StringUtils.isEmpty(idCard)) {
            StringBuilder stringBuilder = new StringBuilder(idCard);
            res = stringBuilder.replace(3, 6, "***").toString();
        }
        return res;
    }


    /**
     * 手机号加*
     * @param phone 护照证号
     * @return
     */
    public static String phoneAddStar(String phone) {
        String res = "";
        if (!StringUtils.isEmpty(phone)) {
            StringBuilder stringBuilder = new StringBuilder(phone);
            res = stringBuilder.replace(3, 8, "*****").toString();
        }
        return res;
    }
}
